import actionTypes from "../actions/actionTypes";
import zh_CN from 'antd/es/locale/zh_CN';

// 获取默认语言设置
const defaultLocale = JSON.parse(window.localStorage.getItem('locale')) || zh_CN

const initState = {
  // "locale": en_US,
  "locale": defaultLocale,
}

/**
 * 接受旧状态，更新成新状态
 */
export default (state = initState, action) => {
  switch (action.type) {
    case actionTypes.CHANGE_LANGUAGE:
      return {
        ...state,
        locale: action.payload.locale
      }
    default:
      return state
  }
}
